<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="resource/jq.js"></script>
</head>
<body>
<form action="http://localhost:8080/json/f2">
    <input type="text" name="username" id="username">
    <button type="button" id="submitBtn">提交</button>
</form>
<script>
    //  ajax跟语言没有关系
    // console.log($);
    $("#submitBtn").click(function () {
        let username = $("#username").val();
        $.ajax({
                url: "http://localhost:8080/json/f2",
                type: 'post',
                data: JSON.stringify({"username":username}),
                contentType: "application/json;charset=utf-8",
                success: function (data) {
                    console.log(data)
                }
            }
        );
    });


</script>
</body>

</html>